package practice.tmp;

import java.util.ArrayList;
import java.util.List;

public class Solution81 {
    public boolean search(int[] nums, int target) {
        int i = 0;
        int j = nums.length - 1;
        while (i <= j) {
            int mid = (i + j) >> 1;
            if (nums[mid] == target) return true;
            if (nums[mid] == nums[j]) {
                j--;
                continue;
            }else if (nums[mid] < nums[j]) {
                if (nums[mid] < target && target <= nums[j]) i = mid + 1;
                else j = mid - 1;
            } else {
                if (nums[mid] > target && target >= nums[i]) j = mid - 1;
                else i = mid + 1;
            }
        }
        return false;
    }

}
